<div id='message-sucess'></div>
<div id="list-midia">
	<?php
		echo link_to(
        	'Adicionar arquivo',
			url_for('midia/new?ref='.$reference.'&ref_value='.$ref_value),
			array(
            	'id' => 'file'
            )
		);
	?>

	<ul>
		<?php foreach($midia as $m): ?>
		<div style="padding: 5px; float: left;">
			<li id="show-img-buttons">
				<?php
					echo link_to(
						image_tag("/uploads/thumb/".$m["arquivo"], array("rel" =>$m["id_midia"])),
						image_path("/uploads/".$m["arquivo"]),
						array(
	                    	'id'        => 'preview',
	                        'title'		=> $m['legenda'],
	                        'rel'		=> 'midia_gallery'
	                    )
	                );
	             ?>
				<div align="right">
					<?php
						echo link_to(
	                    	' ',
							url_for('midia/edit?id_midia='.$m['id_midia'].'&ref='.$reference.'&ref_value='.$ref_value),
							array(
	                        	'class'     => 'icoEditar',
	                        	'id'        => 'file'
	                    	)
	                	);
	                 ?>
	                 <?php
	                 	echo link_to(
	                    	' ',
	                        url_for('midia/delete?id_midia='.$m['id_midia']),
	                        array(
	                        	'class' => 'icoExcluir',
	                            'id'    => 'delete'
	                        )
	                    );
	                 ?>
	             </div>
			</li>
		</div>
		<?php endforeach; ?>
		<div style="clear: both;"></div>
	</ul>
</div>
<script>
    $(function()
    {
        App.modaldata.onClick('file', 'dialog', {width: 600, modal:true, title: 'Controle de arquivo'});
        App.formdata.remove('1');
        App.modaldata.openMidiaBox('midia_gallery', true);
    });
</script>
